package com.aigou.admin.service.impl;

import com.aigou.admin.dao.Carousel_figureDAO;
import com.aigou.admin.dao.impl.Carousel_figureDAOImpl;
import com.aigou.admin.entity.Carousel_figure;
import com.aigou.admin.entity.PageEntity;
import com.aigou.admin.service.Carousel_figureservice;

import java.util.List;

public class Carousel_figureserviceImpl implements Carousel_figureservice {
    private Carousel_figureDAO carousel_figureDAO = new Carousel_figureDAOImpl();

    @Override
    public PageEntity<Carousel_figure> findCarousel_figurePage(Integer current, Integer pageSize) {
        int total = carousel_figureDAO.selectCarousel_figureCount();
        List<Carousel_figure> carousel_figures = carousel_figureDAO.carousel_figureLimit((current - 1) * pageSize,pageSize);
        PageEntity<Carousel_figure> pageEntity = new PageEntity<>();
        pageEntity.setCurrent(current);
        pageEntity.setPageSize(pageSize);
        pageEntity.setTotal(total);
        pageEntity.setRecords(carousel_figures);
        return pageEntity;
    }

    @Override
    public List<Carousel_figure> findAll() {
        return carousel_figureDAO.setAll();
    }

    @Override
    public Carousel_figure findByid(String id) {
        return carousel_figureDAO.selectById(id);
    }

    @Override
    public boolean save(Carousel_figure carousel_figure) {
        return carousel_figureDAO.inser(carousel_figure);
    }

    @Override
    public boolean delete(String id) {
        return carousel_figureDAO.delete(id);
    }

    @Override
    public boolean update(Carousel_figure carousel_figure) {
        return carousel_figureDAO.update(carousel_figure);
    }
}
